//
//
//

#ifndef XLISPQT_XLISPWIDGET_H
#define XLISPQT_XLISPWIDGET_H

#include <QtGui/QPlainTextEdit>

namespace xlispqt {
#if 0
}
#endif

class XlispEngine;

class XlispPlainTextEdit : public QPlainTextEdit
{
	Q_OBJECT
public:
	typedef QPlainTextEdit parent_t;

	explicit XlispPlainTextEdit(QWidget *parent = 0);
    explicit XlispPlainTextEdit(QString const &text, QWidget *parent = 0);

	~XlispPlainTextEdit();

public:
	void init(int argc, char **argv);

signals:
	void inputReady(QString text);
	void quitRequest(int code);

public slots:
	void textWasChanged();
	void shortcutPressed();
	void eval(QString text);

protected:
	virtual void keyPressEvent(QKeyEvent *e);
private:
	void setup();
public:
	static XlispPlainTextEdit *current_instance() { return m_instance; };
    static int consoleGetC();
    static void consoleFlushInput();
    static void consolePutC(int ch);
    static void consoleFlushOutput();
    static int consoleAtBOLP();
    static int consoleCheck();
	static void exit(int sts);
private:
	XlispEngine *m_engine;
	int m_last_cursor_position;
	static XlispPlainTextEdit *m_instance;
};

} // namespace
#endif
